package com.fbs.controller;


import com.fbs.dao.UserDao;
import com.fbs.entity.User;
import com.fbs.service.UserService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    public User findByid(@PathVariable Integer id){
        User byId = userService.findById(id);
        return byId;
    }
    @DeleteMapping ("/{id}")
    public Integer del(@PathVariable Integer id){
        Integer integer = userService.delById(id);
        return integer;
    }
    @PostMapping
    public User save(@RequestBody User user){
        User save = userService.save(user);
        return save;
    }
    @PutMapping
    public User update(@RequestBody User user){
        User update = userService.update(user);
        return update;
    }

}
